package com.hentie.inputlib;

import android.content.Context;
import android.content.pm.PackageManager;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
public class Input implements OnTouchListener {
	
	public static TouchState touchState = null;
	public static final int MAX_TOUCH = 5;	boolean hasTouch = false;
	
	float viewWidth = 1;
	float viewHeight = 1.0f;
	
	public static void SetupInput(Context context)
	{
		PackageManager pkg = context.getPackageManager();
		
		if(pkg.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH))
		{
			//Create the touchstate
			Input.touchState = new TouchState(true,MAX_TOUCH);
		}else
		{
			//Create the touchstate
			Input.touchState = new TouchState(false,1);
		}
			
	}

	public Input()
	{
		
	}
	
	public boolean onTouch(View arg0, MotionEvent ev) {
		
		//Get the view data
		viewWidth = arg0.getWidth();
		viewHeight = arg0.getHeight();
		
		if(ev.getAction() == MotionEvent.ACTION_MOVE || ev.getAction()==MotionEvent.ACTION_DOWN)
		{
			//Update the touch
			touchState.UpdateTouchState(ev,viewWidth,viewHeight);
		}else if(ev.getAction() == MotionEvent.ACTION_UP)
			touchState.NoTouch();
		
		
		// TODO Auto-generated method stub
		return false;
	}

}
